<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>倒计时</title>
</head>
<body>
<script>
        window.onload = function() {
            var i = 10;
            var out = document.getElementById('out');
            var timer = setInterval(function() {
                if(i == -1) {
                    clearInterval(timer);
                    document.write("时间到");
                } else {
                    out.innerHTML = i + "秒";
                    --i;
                }
            }, 1000);
        }
</script>
<a id="out"></a>

</body>
</html>